package com.kermel.andromeda.common.action;

import android.app.Dialog;
import android.content.Context;
import android.view.View;

public abstract class DialogPromptAction extends ViewClickAction  {
    private Dialog dialog;
    private OnCloseListener onCloseListener;
    
    protected abstract Dialog createDialog();
    
    public DialogPromptAction(Context context) {
        super(context);
    }

    public void setOnCloseListener(OnCloseListener listener) {
        if (listener != null)
            onCloseListener = listener;
    }
    
    private void notifyOnClose() {
        if (onCloseListener != null)
            onCloseListener.onChooseAlarmTimeClose();
    }
    
    private void showDialog() {
        dialog.show();
    }
    
    protected void closeDialog() {
        dialog.dismiss();
        notifyOnClose();
    }
    
    
    public void onClick(View view) {
        dialog = createDialog();
        showDialog();
    }

    public static interface OnCloseListener {
        void onChooseAlarmTimeClose();
    }
}
